<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="__EXTEND__/favicon.ico" >
    <link rel="Shortcut Icon" href="__EXTEND__/favicon.ico" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="__EXTEND__/lib/html5shiv.js"></script>
    <script type="text/javascript" src="__EXTEND__/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="__EXTEND__/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="__EXTEND__/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="__EXTEND__/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="__EXTEND__/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="__EXTEND__/static/h-ui.admin/css/style.css" />
    <link href="__EXTEND__/lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="__EXTEND__/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <!--/meta 作为公共模版分离出去-->

    <style>
        .clearfix:after{content:"\20";display:block;height:0;clear:both;visibility:hidden}.clearfix{zoom:1}
        .tabBar {border-bottom: 2px solid #222}
        .tabBar span {background-color: #e8e8e8;cursor: pointer;display: inline-block;float: left;font-weight: bold;height: 30px;line-height: 30px;padding: 0 15px}
        .tabBar span.currentTab{background-color: #222;color: #fff}
        .tabCon {display: none}
    </style>
    <link href="__EXTEND__/ztree/styles/zTree/zTreeStyle.css" rel="stylesheet" type="text/css" />
    <title>页面生成</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 开发工具 <span class="c-gray en">&gt;</span> 页面生成
    </nav>
<div id="tab_demo" class="HuiTab">
    <div class="tabBar clearfix"><span>第一步：页面信息</span><span>第二步：字段设置</span></div>
    <form class="form form-horizontal" id="form-add-12"  method="post">

        <!--第一步：表信息-->
        <div class="tabCon">
                <input type="hidden" name="step" value="{{$step}}" id="step">
            <div class="row cl ">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>表名：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text step1" value="" placeholder="请输入无前缀表名" id="table" name="table">
                    <input type="hidden"  value=""  id="table_name" name="table_name">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>标题：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value=""  placeholder="请输入菜单列表展示的标题" id="title" name="title">
                    <span display="none" style="color:red"  class="show_info"></span>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>导航菜单：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <div class="select-box">
                        <select name="pid" class="select">
                            <option value="">请选择</option>
                            <foreach name="pids" item="pid">
                                <option value="{{$pid['m_id']}}" >{{:str_repeat("&nbsp;&nbsp;|--&nbsp;",$pid['level'])}}{{$pid['title']}}</option>
                            </foreach>
                        </select>
                    </div>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>是否隐藏：</label>
                <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                    <div class="radio-box">
                        <input type="radio" id="hide-1"  name="hide" value="0" checked>
                        <label for="hide-1">否</label>
                    </div>
                    <div class="radio-box">
                        <input name="hide" type="radio"  id="hide-0"  value="1" >
                        <label for="hide-0">是</label>
                    </div>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">排序：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="0" placeholder="用于菜单分组显示的顺序" id="sort" name="sort">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">说明：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" placeholder="菜单详细说明" id="tip" name="tip">
                </div>
            </div>

            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2" style="text-align: center" id="div_step1">
                    <button  class="btn btn-primary radius" id="create_fields" type="button">&nbsp;&nbsp;下一步&nbsp;&nbsp;</button>
                </div>
            </div>
        </div>
        <!--第二步：字段设置-->
        <div class="tabCon" id="check">
                <div class="row cl img">
                    <label class="form-label col-xs-4 col-sm-1">
                    </label>
                    <div class="formControls col-xs-8 col-sm-10">
                        <span  style="color:gray">1、请选择需要的字段生成列表&nbsp;&nbsp;2、默认排序是主键倒序<br>3、默认值为null的必须勾选设置&nbsp;&nbsp;4、字段为add_time，则默认为添加时间，不可勾选设置</span>
                        <table class="table table-border table-bordered table-bg mt-20 table-hover" id="table-field">
                            <thead>
                            <tr class="text-c">
                                <th width="15%">字段</th>
                                <th width="30%">展示标题</th>
                                <th width="15%">默认值</th>
                                <th width="10%">是否设置</th>
                                <th width="10%">是否列表</th>
                                <th width="10%">是否排序</th>
                                <th width="10%">是否搜索</th>
                            </tr>
                            </thead>
                            <tbody >
                            </tbody>
                        </table>
                        <span  style="color:red;display:inline-block;"  class="show_info" ></span>
                    </div>
                </div>
                <div class="row cl">
                    <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2" style="text-align: center">
                        <button onClick="returnOne();" class="btn btn-primary radius" type="button">&nbsp;&nbsp;上一步&nbsp;&nbsp;</button>
                        <input class="btn btn-primary radius" type="text" value="&nbsp;&nbsp;提交&nbsp;&nbsp;" id="step2">
                    </div>
                </div>
        </div>

    </form>

</div>


<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="__EXTEND__/js/jquery-1.8.3.js"></script>

<script type="text/javascript" src="__EXTEND__/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="__EXTEND__/static/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="__EXTEND__/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__EXTEND__/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__EXTEND__/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__EXTEND__/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__EXTEND__/lib/jquery.validation/1.14.0/messages_zh.js"></script>

<script src="__EXTEND__/style/js/exif.js?v=b26c6d5"></script>
<script src="__EXTEND__/style/js/lrz.js?v=c105d63"></script>
<!--upload-->

<script type="text/javascript" src="__EXTEND__/lib/webuploader/0.1.5/webuploader.min.js"></script>
<script>


    $(function() {

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
        $("#create_fields").click(function(){
            var table = $("#table").val();
            if(table == ''){
                layer.msg('表名不能为空',{icon:2,time:1000});
                return false;
            }
            var title = $("#title").val();
            if(title == ''){
                layer.msg('标题不能为空',{icon:2,time:1000});
                return false;
            }
            var pid = $("select[name='pid'] option:selected").val();
            if(pid == ''){
                layer.msg('请选择所属的导航菜单',{icon:2,time:1000});
                return false;
            }
            $.ajax({
                type: 'POST',
                url: '{{:U("Admin/Code/crud",array("step"=>"table"))}}',
                data: {
                    table:table,
                },
                dataType: 'json',
                beforeSend:function(){
                    $("#create_fields").hide();
                },
                success: function(data){
                    if(data.status){

                        $("#create_fields").remove();
                        var btn3 = "<button onClick=\"returnTwo();\" class=\"btn btn-primary radius\" type=\"button\">&nbsp;&nbsp;下一步&nbsp;&nbsp;</button>"
                        $("#div_step1").append(btn3);
                        $("#step").val("field");
                        $(".step1").attr("disabled",true);
                        $("#table_name").val(table);
                        returnTwo();
                        var html = '';
                        $(data.info).each(function(i,v){
                            html += '<tr class=\'text-c  \'>\n' +
                                '<input type="hidden" value="'+i+'" name="field_id[]"><input type="hidden" value="'+v.COLUMN_NAME+'" name="field_name[]">' +
                                '<td>'+v.COLUMN_NAME+'</td>\n';
                            if(v.COLUMN_COMMENT){
                                html += '<td><input type="text" name="field_title[]" value="'+v.COLUMN_COMMENT+'" style="width:90%;height:27px"></td>\n' +
                                    '<td>'+v.COLUMN_DEFAULT+'</td>\n';
                            }else{
                                html += '<td><input type="text" name="field_title[]" value="'+v.COLUMN_NAME+'" style="width:90%;height:27px"></td>\n' +
                                    '<td>'+v.COLUMN_NAME+'</td>\n';
                            }

                            /*设置*/
                            if(v.COLUMN_DEFAULT == null){
                                html += '<td><input type="checkbox" value="'+i+'" checked  name="is_set[]"></td>\n';
                            }else if(v.COLUMN_DEFAULT == '主键,自增长' || v.COLUMN_NAME == 'add_time'){
                                html += '<td><input type="checkbox" value="'+i+'" disabled  name="is_set[]"></td>\n';//主键和添加时间都不能设置
                            }else{
                                html += '<td><input type="checkbox" value="'+i+'" checked name="is_set[]"></td>\n';
                            }
                            /*列表*/
                            html += '<td><input type="checkbox" value="'+i+'" name="is_list[]" checked></td>\n';
                            /*排序*/
                            if(v.COLUMN_DEFAULT == '主键,自增长'){
                                html += '<td><input type="checkbox" value="'+i+'" checked  name="is_sort[]"></td>\n';
                            }else{
                                html += '<td><input type="checkbox" value="'+i+'" name="is_sort[]"></td>\n';
                            }
                            /*搜索*/
                            html += '<td><input type="checkbox" value="'+i+'" name="is_search[]"></td>\n' +
                                '</tr>';
                        });
                        $('#table-field > tbody').append(html);
                    }else{
                        $("#create_fields").show();
                        layer.msg(data.info,{icon:2,time:1000});
                    }
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        })


        //提交
        $("#step2").click(function(){
            $("#step2").hide();
            $("#form-add-12").attr("action","{{:U('Admin/Code/crud',array('step'=>'field'))}}");
            $("#form-add-12").submit();
        })

    });

    function returnOne(){
        $.Huitab("#tab_demo .tabBar span","#tab_demo .tabCon","currentTab","click","0");
    }
    function returnTwo(){
        $.Huitab("#tab_demo .tabBar span","#tab_demo .tabCon","currentTab","click","1");
    }




</script>

<script type="text/javascript" src="__EXTEND__/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="__EXTEND__/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" src="__EXTEND__/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>

<script>
    jQuery.Huitab =function(tabBar,tabCon,class_name,tabEvent,i){
        var $tab_menu=$(tabBar);
        // 初始化操作
        $tab_menu.removeClass(class_name);
        $(tabBar).eq(i).addClass(class_name);
        $(tabCon).hide();
        $(tabCon).eq(i).show();

        $tab_menu.bind(tabEvent,function(){

            if(this.innerText == '第二步：字段设置'){
                var step = $("#step").val();
                if(step != 'field'){
                    layer.msg("请先填写页面信息", {icon: 2, time: 1000});
                    return;
                }
            }
            $tab_menu.removeClass(class_name);
            $(this).addClass(class_name);
            var index=$tab_menu.index(this);
            $(tabCon).hide();
            $(tabCon).eq(index).show()})}
</script>
<script type="text/javascript">
    // #tab_demo 父级id
    // #tab_demo .tabBar span 控制条
    // #tab_demo .tabCon 内容区
    // click 事件 点击切换，可以换成mousemove 移动鼠标切换
    // 1	默认第2个tab为当前状态（从0开始）
    $(function(){

        $.Huitab("#tab_demo .tabBar span","#tab_demo .tabCon","currentTab","click","0");
    });




</script>


<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>